package com.designpatterns.architectural.transferObject;

import com.designpatterns.architectural.dataAccessObject.Student;

import java.util.ArrayList;
import java.util.List;

public class StudentBO {
    private List<StudentVO> students;

    public StudentBO() {
        students = new ArrayList<>();
        StudentVO student1 = new StudentVO("Robert", 0);
        StudentVO student2 = new StudentVO("John", 1);
        students.add(student1);
        students.add(student2);
    }

    public List<StudentVO> getAllStudents() {
        return students;
    }

    public StudentVO getStudent(Integer rollNo) {
        return students.get(rollNo);
    }

    public void updateStudent(StudentVO student) {
        students.get(student.getRollNo()).setName(student.getName());
        System.out.println("Student: Roll No " + student.getRollNo() + ", updated in database");
    }

    public void deleteStudent(Student student) {
        students.remove(student.getRollNo());
        System.out.println("Student: Roll No " + student.getRollNo() + ", deleted from database");
    }
}
